const { Controller } = require('egg');

class HomeController extends Controller {
  async index() {
    const { ctx } = this;
    ctx.body = 'hi, egg';
  }

  async test() {
    const { ctx } = this;
    try {
      const result = await this.app.mysql.query('SELECT 1');
      ctx.body = {
        success: true,
        data: result
      };
    } catch (error) {
      ctx.body = {
        success: false,
        error: error.message
      };
    }
  }
}

module.exports = HomeController;
